﻿@using KRM.Core
@model List<KRM.Core.WebPermissionMenuLink>
@{
    ViewBag.Title = "MenuEditor";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var db = new KRMEntities();
}
<div id="addMenuLink" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addController" aria-hidden="true">
    <form action="/permission/createmenulink" method="POST" class="margin0">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h5>New menu link</h5>
        </div>
        <div class="modal-body">
            <div class="row-fluid">
                <div class="span4">
                    Expando
                </div>
                <div class="span7">
                    @Html.DropDownList("ExpandoID")
                </div>
            </div>
            <div class="row-fluid">
                <div class="span4">Link text</div>
                <div class="span7">
                    <input type="text" name="Name" required="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span4">Link</div>
                <div class="span7">
                    <input type="text" name="Link" required="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span4">
                    Department<br />
                    <small>ctrl + click to select many</small>
                </div>
                <div class="span7">
                    @Html.DropDownList("Department", null, new { multiple = "multiple" })
                </div>
            </div>
        </div>

        <div class="modal-footer">
            <input type="submit" value="Create" class="btn btn-primary" />
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div>
    </form>
</div>
<div class="container-fluid">
    <div class="box">
        <div class="box-title">
            <h3>Menu editor</h3>
        </div>
        @Html.Partial("Partial/_MessageResult")
        <div class="row-fluid">
            <div class="tbl-menulink">
                <table class="table table-bordered table-fix tbl-menueditor">
                    <thead>
                        <tr>
                            <th>Link text</th>
                            <th>Link</th>
                            <th>Expando</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.OrderByDescending(a => a.WebPermissionExpando.Position).ThenBy(a => a.WebPermissionExpando.Name))
                        {
                            <tr onclick="menudetail(@item.ID)" style="cursor: pointer">
                                <td>@item.Name</td>
                                <td>@item.Link</td>
                                <td>@item.WebPermissionExpando.Name</td>
                                <td><a href="/permission/deletemenulink/@item.ID" onclick="javascript:return confirm('Are you sure?');">Delete</a></td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <div class="text-right">
                <a class="btn btn-success" style="margin-top: 10px" data-toggle="modal" href="#addMenuLink">Add new link</a>
                <a href="/permission/controllereditor" class="btn btn-primary" style="margin-top: 10px; margin-left: 10px">Controller permission</a>
                <a href="/permission/expandos" class="btn btn-primary" style="margin-top: 10px; margin-left: 10px">Edit Expandos</a>
            </div>
        </div>
        <form action="/permission/editmenudetail" method="POST" class="row-fluid fr-menudetail">
            <div class="span5" style="margin-top: 20px;">
                <div class="row-fluid">
                    <div class="span3">Expando</div>
                    <div class="span8">
                        <select>
                            <option>Choose</option>
                        </select>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span3">Link text</div>
                    <div class="span8">
                        <input type="text" class="input-block-level" name="name" required="required" />
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span3">Link</div>
                    <div class="span8">
                        <input type="text" class="input-block-level" name="Link" required="required" />
                    </div>
                </div>
            </div>
            <fieldset class="span4">
                <legend>Department</legend>
                <div style="height: 128px; overflow: auto">
                    @foreach (var item in db.WebPermissionDepartments)
                    {
                        <div class="control">
                            <label class="checkbox">
                                <input type="checkbox" name="Department@(item.ID)" value="@item.ID"/>
                                @item.Name
                            </label>
                        </div>
                    }
                </div>
            </fieldset>
        </form>
    </div>
</div>
